const isAndroid  = navigator.userAgent.toLowerCase().indexOf('android')>0;
console.log("平台类型 isAndroid:"+isAndroid+",userAgent:"+navigator.userAgent);

async function loadFile() {
    try {
      // 获得文件夹的句柄
      const handle = await showDirectoryPicker();
      const root = await processHandler(handle);//深层遍历文件
      console.log(root)



      //   获得文件内容
      const file = await root.children[1].getFile();
      const reader = new FileReader();
      reader.onload = e => {
        // 读取结果
        folderCount = e.target.result;
        console.log(e.target.result) //文件读入地图
      }
      reader.readAsText(file, 'utf-8')
    }
    catch (e) {
      //用户拒绝查看文件
      alert(e)
    }
  }

  //处理句柄
  async function processHandler(handle) {
    if (handle.kind === 'file') {
      return handle
    }
    handle.children = []
    const iter = await handle.entries();//获得文件夹中的所有内容
    //iter:异步迭代器
    for await (const info of iter) {
      var subHandle = await processHandler(info[1]);
      handle.children.push(subHandle)
    }
    return handle
  }


  function readContent(fileHnadler){
    
  }